package likong.bibliothek.pages.language;

import likong.bibliothek.obj.Language;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.hibernate.Session;


import db.HibernateHelper;

public class LanguageNeu extends LanguageAbstract {
	public LanguageNeu(){
		Language language = new Language();
		final CompoundPropertyModel<Language> model = new CompoundPropertyModel<Language>(language );
		
		// Panel einfügen
		add(new LanguageFormPanel("neuerLanguageFormular", model, "Sprache einfügen") {
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmitModelHandle(IModel<Language> model) {
				Session session = HibernateHelper.getSessionFactory().getCurrentSession();
				session.beginTransaction();
				session.save(model.getObject());
				session.getTransaction().commit();
//				session.close();
				
				
				this.setResponsePage(LanguageWeb.class);
			}
		});
	}

}
